package com.dadie.dorm.service.impl;




import com.dadie.dorm.dao.IDormbuildDao;
import com.dadie.dorm.dao.impl.DormbuildDaoImpl;
import com.dadie.dorm.pojo.Dormbuild;
import com.dadie.dorm.pojo.query.DormbuildQuery;
import com.dadie.dorm.pojo.vo.DormbuildCountVO;
import com.dadie.dorm.service.IDormbuildService;
import com.dadie.dorm.util.LayUITableResult;

import java.util.List;

public class DormbuildServiceImpl implements IDormbuildService {
    public IDormbuildDao dormbuildDao=new DormbuildDaoImpl();
    @Override
    public LayUITableResult selectByPage(DormbuildQuery dormbuildQuery) {
        List<Dormbuild> list=dormbuildDao.selectByPage(dormbuildQuery);
        Integer totalCount=dormbuildDao.selectTotalCount(dormbuildQuery);
        return LayUITableResult.ok(totalCount,list);
    }

    @Override
    public boolean deleteById(int id) {
        int count=dormbuildDao.deleteById(id);
        return count==1 ? true: false;
    }

    @Override
    public boolean add(Dormbuild dormbuild) {
        int count=dormbuildDao.add(dormbuild );
        return count==1 ? true: false;
    }

    @Override
    public List<DormbuildCountVO> selectDormbuildCount() {
        return dormbuildDao.selectDormbuildCount();
    }


    @Override
    public boolean deleteAll(String[] ids) {
        // delete from dormbuild where id in();
        int count = 0;
        for (String id : ids) {
            count += dormbuildDao.deleteById(Integer.parseInt(id));
        }
        return count == ids.length ? true : false;
    }

    @Override
    public boolean update(Dormbuild dormbuild) {
        int count=dormbuildDao.update(dormbuild);
        return count==1 ? true: false;
    }

    @Override
    public Dormbuild selectById(int id) {
        return dormbuildDao.selectById(id);

    }
}
